b = input().replace(' ', '')
a = ''
for s in b:
    if s in '(){}[]<>':
        a = a + s
print(a)
while '{}' in a or '[]' in a or '()' in a or '<>' in a:
    a = a.replace('[]', '')
    a = a.replace('{}', '')
    a = a.replace('()', '')
    a = a.replace('<>', '')
if len(a) > 0:
    print('False')
else:
    print('True')